<?php

//header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() - 3600));
header ('Content-type: text/html; charset=UTF-8'); 



?>

<script src="system.js"></script>

<script language="javascript" type="text/javascript">

					
	function submitbutton(pressbutton) 
	{
		//var form = document.adminForm;
	
		switch( pressbutton )
		{
			
			case	"send":
			{
				
					
					
					var oObject = {} ;
					
					oObject["email"] = getInputValueElementId( "email" );
					oObject["password"] = getInputValueElementId( "password" );
					oObject["component"] = "authentication";
					oObject["controller"] = "user";
					oObject["task"] = "login";
					
					
					var jsonVales	=	convertToJSON(oObject);
					
					parameters	=	'parameters='+encodeURIComponent(
											convertToStringJSON(jsonVales));
					
					var method='GET';
						
					httpRequest ( method,
									url_API,
									parameters,
									'returnLogin');
								
						
					return false;
				
				
			}break;
			default:
			{
				
			}
		}	
		
	}


function returnLogin(jsonObj){
	
	if( jsonObj.status == 1){
		
		//if(jsonObj.notification == 1)
			window.location.href='home_authenticated.php';
		//else
		//	alert( "data: "+jsonObj.data );
			
	}else{
		alert( jsonObj.data );
	}
	
}


   	
</script>

</script>

<h1>Página inicial (não autenticado)</h1>
<div id="text-result-hidden" style="visibility:hidden;width:1px;height:1px;"></div>
<div id="text-result">Login</div>
 
<form class="cmxform" action="" method="GET">	

	<div id="label">e-mail</div> <div id="field"><input type="text" id="email" name="email"/></div>
	<div id="label">senha</div> <div id="field"><input type="password" id="password" name="password"/></div>
	
	<input type="button" name="enviar" value="Login" onclick="javascript:submitbutton('send');"/>
	
</form>


<a href="create_user.php">Create login</a>

<script>
verity_authenticated();
</script>
